package com.example.springbootjson.parser;

import com.example.springbootjson.vo.School;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

public class KsDmpSourceSerialize2 extends JsonSerializer<String> {
    public KsDmpSourceSerialize2() {
        System.out.println("KsDmpSourceSerialize2 init");
    }

    @Override
    public void serialize(String s, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        jsonGenerator.writeString("ddd");
        jsonGenerator.writeFieldName("schoolInfo");
        School school = new School();
        school.setName("beida");
        jsonGenerator.writeObject(school);
    }
}
